<%@ Page Language="C#" MasterPageFile="~/Admin.master" AutoEventWireup="true" CodeFile="Posts.aspx.cs" Inherits="Posts" Title="Untitled Page" ValidateRequest="false" %>

<%@ Register Assembly="Acms.AcmsControls" Namespace="Acms.AcmsControls" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="phMain" Runat="Server">

    <div style="float:left">
    <fieldset>
        <legend>Site Map</legend>
        <asp:TreeView ID="tvSiteMap" runat="server" ExpandDepth="2" PopulateNodesFromClient="true" DataSourceID="dsSiteMap" ShowLines="True" OnSelectedNodeChanged="tvSiteMap_SelectedNodeChanged" OnTreeNodeDataBound="tvSiteMap_TreeNodeDataBound">
            <DataBindings>
                <asp:TreeNodeBinding DataMember="SiteMapNode" TextField="Title" ValueField="Key" />
            </DataBindings>
            <SelectedNodeStyle ForeColor="#C00000" />
        </asp:TreeView>
        <div id="divNoHomePage" visible="false" runat="server">There is no home page set up please create one.</div>
    </fieldset>
    </div>
    <div id="divDetails" visible="false" runat="server">
        <fieldset>
            <legend>Details</legend>
        <asp:DetailsView ID="dvPost" runat="server" DataSourceID="dsPost" DataKeyNames="Id,ConcurencyId" AutoGenerateRows="False" OnDataBound="dvPost_DataBound" OnItemDeleted="dvPost_ItemDeleted" OnItemInserted="dvPost_ItemInserted" OnItemUpdated="dvPost_ItemUpdated" OnItemCommand="dvPost_ItemCommand" OnModeChanged="dvPost_ModeChanged" >
            <Fields>
                <asp:BoundField DataField="Id" HeaderText="Id" InsertVisible="False" ReadOnly="True"
                    SortExpression="Id" />
                <asp:TemplateField HeaderText="Name" SortExpression="Name">
                    <EditItemTemplate>
                        <asp:TextBox ID="txtNameEdit" runat="server" Text='<%# Bind("Name") %>'></asp:TextBox>
                    </EditItemTemplate>
                    <InsertItemTemplate>
                        <asp:TextBox ID="txtNameInsert" runat="server" Text='<%# Bind("Name") %>'></asp:TextBox>
                    </InsertItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="lblNameView" runat="server" Text='<%# Bind("Name") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="DisplayName" HeaderText="DisplayName" SortExpression="DisplayName" />
                <asp:BoundField DataField="Path" HeaderText="Path" InsertVisible="False" ReadOnly="True"
                    SortExpression="Path" />
                <asp:BoundField DataField="ParentPath" HeaderText="Parent Path" InsertVisible="False"
                    ReadOnly="True" SortExpression="ParentPath" />
                <asp:TemplateField HeaderText="TemplateName" SortExpression="TemplateName">
                    <EditItemTemplate>
                        <asp:DropDownList ID="ddlTemplateEdit" runat="server" DataSourceID="dsTemplates" DataTextField="Name"
                            DataValueField="Id" SelectedValue='<%# Bind("TemplateId") %>'>
                        </asp:DropDownList>
                    </EditItemTemplate>
                    <InsertItemTemplate>
                        <asp:DropDownList ID="ddlTemplateInsert" runat="server" DataSourceID="dsTemplates" DataTextField="Name"
                            DataValueField="Id" SelectedValue='<%# Bind("TemplateId") %>'>
                        </asp:DropDownList>
                    </InsertItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="Label1" runat="server" Text='<%# Bind("TemplateName") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Summary" SortExpression="Summary">
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox1" TextMode="MultiLine" runat="server" Text='<%# Bind("Summary") %>'></asp:TextBox>
                    </EditItemTemplate>
                    <InsertItemTemplate>
                        <asp:TextBox ID="TextBox1" TextMode="MultiLine" runat="server" Text='<%# Bind("Summary") %>'></asp:TextBox>
                    </InsertItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="Label2" runat="server" Text='<%# Bind("Summary") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Thumbnail">
                    <InsertItemTemplate>
                        <asp:FileUpload ID="fuThumb" runat="server" />
                    </InsertItemTemplate>
                    <EditItemTemplate>
                        <asp:FileUpload ID="fuThumb" runat="server" />
                        <br />
                        <acms:AcmsImage id="imgThumb" FileId='<%#Eval("ThumbnailId") %>' RenderHeight="50" RenderWidth="50" runat="server" />
                    </EditItemTemplate>
                    <ItemTemplate>
                        <acms:AcmsImage id="imgThumb" FileId='<%#Eval("ThumbnailId") %>' RenderHeight="50" RenderWidth="50" runat="server" />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Make Child">
                    <ItemTemplate>
                        <asp:Repeater ID="rptSiblings" runat="server" OnItemCommand="rptSiblings_ItemCommand">
                            <HeaderTemplate><ul></HeaderTemplate>
                            <ItemTemplate><li><asp:LinkButton ID="lnkSibling" CommandName="MakeChild" CommandArgument='<%#Eval("Value") %>' Text='<%#Eval("Text") %>' runat="server" /></li></ItemTemplate>
                            <FooterTemplate></ul></FooterTemplate>
                        </asp:Repeater>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField ShowHeader="False">
                    <EditItemTemplate>
                        <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" CommandName="Update"
                            Text="Update"></asp:LinkButton>
                        <asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Cancel"
                            Text="Cancel"></asp:LinkButton>
                    </EditItemTemplate>
                    <InsertItemTemplate>
                        <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" CommandName="Insert"
                            Text="Insert"></asp:LinkButton>
                        <asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Cancel"
                            Text="Cancel"></asp:LinkButton>
                    </InsertItemTemplate>
                    <ItemTemplate>
                        <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Edit"
                            Text="Edit"></asp:LinkButton>
                        <asp:LinkButton ID="LinkButton3" runat="server" CausesValidation="False" CommandName="Delete"
                            Text="Delete"></asp:LinkButton>
                        <div class="listCommands">
                            <asp:LinkButton ID="LinkButton2" CssClass="item" runat="server" CausesValidation="False" CommandName="AddChild"
                            Text="Add Child"></asp:LinkButton>
                            <asp:LinkButton ID="btnAddSibling" runat="server" CausesValidation="False" CommandName="AddSibling"
                                CssClass="item" Text="Add Sibling"></asp:LinkButton>
                            <asp:LinkButton ID="btnMoveUp"  CssClass="item" runat="server" OnClick="btnMoveUp_Click">Move Up</asp:LinkButton>
                            <asp:LinkButton ID="btnMoveParent"  CssClass="item" runat="server" OnClick="btnMoveParent_Click">Move To Parent</asp:LinkButton>
                        </div>
                    </ItemTemplate>
                </asp:TemplateField>
            </Fields>
        </asp:DetailsView>
        </fieldset>
    </div>
    <div>
        <div id="divMenus" visible="false" class="float:left;width:auto;" runat="server">
            <fieldset>
                <legend>Menus</legend>
                <acmswc:CheckBoxList id="cblMenus" DataSourceID="dsMenus" runat="server" DataTextField="Name" DataValueField="Id" DataCheckedField="DefaultForAllPosts" OnItemDataBound="cblMenus_ItemDataBound"/>
                <asp:Button ID="btnSaveMenus" runat="server" OnClick="btnSaveMenus_Click" Text="Save Changes" />
            </fieldset>
        </div>
        <div id="divTopics" visible="false" class="float:left;width:auto;" runat="server">
            <fieldset>
                <legend>Topics</legend>
                <acmswc:CheckBoxList ID="cblTopics" DataSourceID="dsTopics" runat="server" DataTextField="Name" DataValueField="Id" OnItemDataBound="cblTopics_ItemDataBound">
                </acmswc:CheckBoxList>
                <asp:Button ID="btnSaveTopics" runat="server" OnClick="btnSaveTopics_Click" Text="Save Changes" />
            </fieldset>
        </div>
    </div>
    <div id="divControls" visible="false" runat="server">
        <fieldset><legend>Contents</legend>
            <asp:DataList ID="dlPostControls" runat="server" DataSourceID="dsPostControls" RepeatLayout="Flow" OnEditCommand="dlPostControls_EditCommand" OnItemCreated="dlPostControls_ItemCreated" OnItemDataBound="dlPostControls_ItemDataBound" OnDataBinding="dlPostControls_DataBinding" OnCancelCommand="dlPostControls_CancelCommand" OnUpdateCommand="dlPostControls_UpdateCommand" OnDeleteCommand="dlPostControls_DeleteCommand">
                <ItemTemplate>
                    <div style="min-width:75%">
                        <asp:Label ID="lblControlName" runat="server" Text='<%# Eval("Name") %>'></asp:Label>
                        <asp:Button ID="btnEdit" Text="Edit" CommandName="Edit" runat="server" />
                        <asp:Button ID="btnDelete" Text="Delete" CommandName="Delete" OnClientClick="javascript:return confirm('Are you sure you want to delete?');" runat="server" />
                    </div>
                    <asp:Label ID="lblError" Visible="false" runat="server" />
                    <asp:PlaceHolder ID="phControl" runat="server" />
                    <hr />
                </ItemTemplate>
                <EditItemTemplate>
                    <div style="min-width:75%">
                        <asp:Label ID="lblControlName" runat="server" Text='<%# Eval("Name") %>'></asp:Label>
                        <asp:Button ID="btnSave" Text="Save" CommandName="Update" runat="server" />
                        <asp:Button ID="btnCancel" Text="Cancel" CommandName="Cancel" runat="server" />
                    </div>
                    <asp:Label ID="lblError" Visible="false" runat="server" />
                    <asp:PlaceHolder ID="phControl" runat="server" />
                    <hr />
                </EditItemTemplate>
            </asp:DataList>&nbsp;
        </fieldset>
    </div>
    <div id="divUnusedControls" visible="false" title="Unused Post Controls" runat="server">
        <fieldset>
            <legend>Unused Contents</legend>
                <asp:DataList ID="dlUnused" DataSourceId="dsUnused" OnItemCreated="dlUnused_ItemCreated" OnItemDataBound="dlUnused_ItemDataBound"  runat="server">
                    <ItemTemplate>
                        <div>
                            <asp:Label ID="lblUnusedName" Text='<%#Eval("Name")%>' runat="server"/>
                        </div>
                        <asp:Label ID="lblError" Visible="false" runat="server" />
                        <asp:PlaceHolder ID="phControl" runat="server" />
                        <hr />
                    </ItemTemplate>
                </asp:DataList>
        </fieldset>
    </div>
    <acmsdc:PostDataSource ID="dsPost" runat="server" OnSelectData="dsPost_SelectData" OnUpdatingData="dsPost_UpdatingData" />
    <asp:SiteMapDataSource ID="dsSiteMap" runat="server" SiteMapProvider="AcmsSiteMap" />
    <acmsdc:TemplateDataSource ID="dsTemplates" runat="server" OnSelectData="dsTemplates_SelectData"/>
    <acmsdc:MenuDataSource ID="dsMenus" runat="server" OnSelectData="dsMenus_SelectData"/>
    <acmsdc:PostControlDataSource ID="dsPostControls" runat="server" OnSelectData="dsPostControls_SelectData"/>
    <acmsdc:TopicDataSource ID="dsTopics" runat="server" OnSelectData="dsTopics_SelectData" />
    <acmsdc:UnusedPostControlDataSource ID="dsUnused" runat="server" OnSelectData="dsUnused_SelectData" />
</asp:Content>

